home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / SICL / data1.cab / sicl32 / c / samples / misc / siclmem.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-02  |  2.5 KB  |  85 lines

  1. /*
  2.    siclmem.c
  3.    This example program demonstrates the use of
  4.    simple and block memory I/O methods in SICL.
  5. */
  6.  
  7. #include <sicl.h>
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10.  
  11. #define VXI_INST "vxi,24"
  12.  
  13. void main () {
  14.    INST           id;
  15.    unsigned long  memPtr16;
  16.    unsigned short id_reg;
  17.    unsigned short devtype_reg;
  18.    unsigned short memArray[2];
  19.    int            err;
  20.  
  21.    /* Open a session to our instrument */
  22.    id = iopen(VXI_INST);
  23.  
  24.    /* Map into memory space */
  25.    memPtr16 = imapx(id, I_MAP_VXIDEV, 0, 1);
  26.  
  27.    /* ================== using peek ================================
  28.       Read instrument id register contents */
  29.    ipeekx16(id, memPtr16, 0x0, &id_reg);
  30.  
  31.    /*
  32.       Read device type register contents
  33.    */
  34.    ipeekx16(id, memPtr16, 0x2, &devtype_reg);
  35.  
  36.    /* Print results */
  37.    printf(" ipeekx16: ID Register = 0x%04X\n", id_reg);
  38.    printf(" ipeekx16: Device Type Register = 0x%04X\n", devtype_reg);
  39.  
  40.    /*
  41.    ==================================================================
  42.    ======================== block memory I/O ========================
  43.       = iblockmovex
  44.  
  45.    This command offers the best performance for reading and writing
  46.    large data blocks on the VXI backplane.  Note that for this
  47.    example we are only moving 2 words at a time.  Normally this
  48.    function would be used to move much larger blocks of data.
  49.    ==================================================================
  50.    ==================================================================
  51.    */
  52.    
  53.    /*
  54.    ================== Demonstrate block read ========================
  55.    Read the instrument id register and device type register into
  56.    an array.
  57.    */
  58.    err = iblockmovex(id, memPtr16, 0, 16, 1, 0, (unsigned long)memArray, 16, 1, 2, 1);
  59.  
  60.    /* Print results */
  61.    printf(" iblockmovex: ID Register = 0x%04X\n", memArray[0]);
  62.    printf(" iblockmovex: Device Type Register = 0x%04X\n", memArray[1]);
  63.  
  64.    /*
  65.    ==================== Demonstrate popfifo =========================
  66.    */
  67.    
  68.    /* Do a popfifo of the Id Register */
  69.    err = iblockmovex(id, memPtr16, 0, 16, 0, 0, (unsigned long)memArray, 16, 1, 2, 1);
  70.    
  71.    /* Print results */
  72.    printf(" iblockmovex(fifo): 1 ID Register = 0x%04X\n", memArray[0]);
  73.    printf(" iblockmovex(fifo): 2 ID Register = 0x%04X\n", memArray[1]);
  74.  
  75.    /*
  76.    ===================== Cleanup and exit ===========================
  77.    */
  78.  
  79.    /* Unmap memory space */
  80.    iunmapx(id, memPtr16, I_MAP_VXIDEV, 0, 1);
  81.  
  82.    /* Close instrument session */
  83.    iclose(id);
  84. }
  85.